public class Main {
    public static int BinarySearch(int[] arrays,int value){
        int begin = 0;
        int end = arrays.length - 1;
        while(begin <= end){
            int mid = begin + ((end-begin) / 2);
            if (arrays[mid] < value){
                begin = mid + 1;
            }else if(arrays[mid] > value){
                end = mid - 1;
            }else{
                return mid;
            }
        }
        return -1;
    }
}
